package utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.part;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.providers.UpcolbpipElementTypes;

/**
 * @generated
 */
public class UpcolbpipPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createInteractionProtocols1Group());
	}

	/**
	 * Creates "Interaction Protocols" palette tool group
	 * @generated
	 */
	private PaletteContainer createInteractionProtocols1Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.InteractionProtocols1Group_title);
		paletteContainer.add(createPartnerRole1CreationTool());
		paletteContainer.add(createBusinessMessage2CreationTool());
		paletteContainer.add(createControlFlowSegment3CreationTool());
		paletteContainer.add(createInteractionPath4CreationTool());
		paletteContainer.add(createTermination5CreationTool());
		paletteContainer.add(createProtocolReference6CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPartnerRole1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(UpcolbpipElementTypes.Role_2005);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.PartnerRole1CreationTool_title,
				Messages.PartnerRole1CreationTool_desc, types);
		entry.setSmallIcon(UpcolbpipElementTypes
				.getImageDescriptor(UpcolbpipElementTypes.Role_2005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createBusinessMessage2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(UpcolbpipElementTypes.BusinessMessage_4001);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.BusinessMessage2CreationTool_title,
				Messages.BusinessMessage2CreationTool_desc, types);
		entry
				.setSmallIcon(UpcolbpipElementTypes
						.getImageDescriptor(UpcolbpipElementTypes.BusinessMessage_4001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createControlFlowSegment3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(UpcolbpipElementTypes.ControlFlowSegment_2002);
		types.add(UpcolbpipElementTypes.ControlFlowSegment_3002);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ControlFlowSegment3CreationTool_title,
				Messages.ControlFlowSegment3CreationTool_desc, types);
		entry
				.setSmallIcon(UpcolbpipElementTypes
						.getImageDescriptor(UpcolbpipElementTypes.ControlFlowSegment_2002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInteractionPath4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(UpcolbpipElementTypes.InteractionPath_3001);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.InteractionPath4CreationTool_title,
				Messages.InteractionPath4CreationTool_desc, types);
		entry
				.setSmallIcon(UpcolbpipElementTypes
						.getImageDescriptor(UpcolbpipElementTypes.InteractionPath_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createTermination5CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(UpcolbpipElementTypes.Termination_2003);
		types.add(UpcolbpipElementTypes.Termination_3004);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Termination5CreationTool_title,
				Messages.Termination5CreationTool_desc, types);
		entry.setSmallIcon(UpcolbpipElementTypes
				.getImageDescriptor(UpcolbpipElementTypes.Termination_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createProtocolReference6CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types.add(UpcolbpipElementTypes.ProtocolReference_2004);
		types.add(UpcolbpipElementTypes.ProtocolReference_3003);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ProtocolReference6CreationTool_title,
				Messages.ProtocolReference6CreationTool_desc, types);
		entry
				.setSmallIcon(UpcolbpipElementTypes
						.getImageDescriptor(UpcolbpipElementTypes.ProtocolReference_2004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
